package com.blueheart.music.service.impl;

import com.blueheart.music.mapper.CommentMapper;
import com.blueheart.music.model.pojo.Comment;
import com.blueheart.music.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author gali
 * @date 2022/4/9 15:05
 */
@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;
    /**
     * 增加评论
     *
     * @param comment
     * @return
     */
    @Override
    public boolean addComment(Comment comment) {
        return commentMapper.insertSelective(comment)>0;
    }

    /**
     * 删除评论
     *
     * @param id
     * @return
     */
    @Override
    public boolean removeComment(Integer id) {
        return commentMapper.deleteByPrimaryKey(id)>0;
    }

    /**
     * 更改评论
     *
     * @param comment
     * @return
     */
    @Override
    public boolean reviseComment(Comment comment) {
        return commentMapper.updateByPrimaryKeySelective(comment)>0;
    }

    /**
     * 查询全部评论
     *
     * @return
     */
    @Override
    public List<Comment> findAll() {
        return commentMapper.selectAll();
    }

    /**
     * 查询该歌单的评论
     *
     * @param songListId
     * @return
     */
    @Override
    public List<Comment> findBySongListId(Integer songListId) {
        return commentMapper.selectBySongListId(songListId);
    }

    /**
     * 查询该歌曲的评论
     *
     * @param songId
     * @return
     */
    @Override
    public List<Comment> findBySongId(Integer songId) {
        return commentMapper.selectBySongId(songId);
    }

    /**
     * 增加评论数
     *
     * @param comment
     * @return
     */
    @Override
    public boolean addUp(Comment comment) {
        return commentMapper.updateByUp(comment)>0;
    }
}
